<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of BService
 *
 * @author jianfeng
 */
class BService {
    /*
     * workTeam,servedTeam and friendTeam are instance of BServiceTeam
     */
    
    const NewService = 0;
    
    protected $workTeam = null;
    protected $servedTeam = null;
    protected $friendTeam = array();
    protected $serviceApps = array();
    /*
     * $myApp is a instance of BApplication
     */
    protected $myApp = null;
    
    public function __construct($serviceId = null,$config = null) {
        $this->myApp = new BServiceAppForService($this);
        $this->workTeam = new BServiceTeam($this);
        $this->servedTeam = new BServiceTeam($this);
        $this->friendTeam = new BServiceTeam($this);       
        $this->serviceApps = array();
        
        if($serviceId != null)
        {
            if($serviceId ==  BService::NewService)
            {
                $this->createNewService($config);
            }
            else
                $this->loadService ($config);
        }
    }
    
    public function createNewService($config)
    {    
       return $this->myApp->doOperation("createNewService",$config);
    }
    
    public function loadService($config)
    {
        return $this->myApp->doOperation("loadService",$config);
    }
    
    public function setServiceName($name)
    {
        return $this->myApp->doOperation("setServiceName",$name);
    }
    
    public function checkAccess($operation)
    {
        return $myApp->checkAccess($operation);
    }
}

?>
